import re


def getUrl():
    urlRegex = re.compile(r'(https|ftp|file://)([A-Za-z0-9-+&@#/%?=~_|!:,.;]+[A-Za-z0-9-+&@#/%=~_|])')
    matches = []
    obj = open('txt/url.txt', 'w')
    with open('txt/news.txt','r') as file:
        text = file.read()
    for groups in urlRegex.findall(text):
        urlNum = ''.join([groups[0],groups[1]])
        matches.append(urlNum)
    url = '\n'.join(matches)
    obj.writelines(url)
    obj.close()
